﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Platform.Model.Validations
{
	/// <summary>
	/// Ket qua kiem tra tinh hop le du lieu
	/// </summary>
	public class ValidationResult
	{
		/// <summary>
		/// Danh sach cac thong bao loi
		/// </summary>
		public List<string> Messages { get; set; }

		/// <summary>
		/// Cho biet du lieu co hop le hay khong
		/// </summary>
		public bool Valid
		{
			get { return !Messages.Any(); }
		}

		/// <summary>
		/// Khoi tao ket qua kiem tra tinh hop le
		/// </summary>
		public ValidationResult()
		{
			Messages = new List<string>();
		}

		/// <summary>
		/// Lay chuoi mo ta cac loi du lieu
		/// </summary>
		/// <returns>Chuoi mo ta cac loi du lieu khong hop le</returns>
		public override string ToString()
		{
			var sb = new StringBuilder();
			Messages.ForEach(m => sb.AppendLine(m));
			return sb.ToString();
		}
	}
}
